package com.cea.papyrus.core.commands;

import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.gef.commands.Command;

/**
 * Wrap command for EMF Change commands
 */
public class EMFtoGEFWrapCommand extends Command {

	/** Wrapped EMF command */
	org.eclipse.emf.common.command.Command emfCommand;
	
	/** Editing domain used by the EMF command */
	protected EditingDomain editingDomain;

	/**
	 * Creates a new EMFtoGEFWrapCommand
	 * @param runnable the runnable executed by the command
	 */
	public EMFtoGEFWrapCommand(org.eclipse.emf.common.command.Command command) {
		emfCommand = command;
	}
	
	/**
	 * Creates a new EMFtoGEFWrapCommand.
	 * It creates the command using the createEMFCommand() method, which should be 
	 * overloaded by 
	 * @param editingDomain the associated editing domain, to launch the wrapped EMF command
	 */
	public EMFtoGEFWrapCommand(EditingDomain editingDomain) {
		this.editingDomain = editingDomain;
		emfCommand = createEMFCommand();
	}

	public org.eclipse.emf.common.command.Command createEMFCommand() { return emfCommand; }
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void execute() {
		emfCommand.execute();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean canExecute() {
		return emfCommand.canExecute();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean canUndo() {
		return emfCommand.canUndo();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void undo() {
		emfCommand.undo();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void redo() {
		emfCommand.redo();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getLabel() {
		return emfCommand.getLabel();
	}
}